
// 键头函数 屏蔽this
// nums [2,7,11,15];
// target=9;
// for o(n2) -> o(n)
/**
 * @func towSum 两数之和
 * @params num:int[], target:int
 * @desc 用暴力破解o(n2),怎么优化？
 * @return []
 */
const towSum= (nums,target) =>{
    // console.log(this.name,'----');
    let arr=[];
    for(let i=0; i<nums.length; i++){
        for(let j=i+1;j<nums.length;j++){
            if(nums[i]+nums[j]==target){
                arr=[i,j];
                break;
            }
        }
    }
    return arr;
}

console.log(towSum([2,7,11,15],9));
/* var name='力扣';

const obj ={
    name:'leetcode',
    towSum
}

obj.towSum(); */